export default () => {
  /** 状态栏高度 */
  const statusBarHeight = computed(() => {
    const { statusBarHeight } = uni.getSystemInfoSync();
    return statusBarHeight ?? 0;
  });
  /** 导航栏高度 */
  const navBarHeight = computed(() => {
    const { statusBarHeight } = uni.getSystemInfoSync();
    if (statusBarHeight === undefined) return 0;

    // #ifndef H5
    const { bottom, top } = uni.getMenuButtonBoundingClientRect();
    return bottom - statusBarHeight + top - statusBarHeight;
    // #endif
    // #ifdef H5
    return 45;
    // #endif
  });
  /** 胶囊按钮 */
  const menuButtonBounding = computed(() => {
    // #ifndef H5
    const data = uni.getMenuButtonBoundingClientRect();
    const { windowWidth } = uni.getSystemInfoSync();
    return {
      height: data?.height ?? 0,
      width: data?.width ?? 0,
      top: data?.top ?? 0,
      left: data?.left ?? 0,
      bottom: data?.bottom ?? 0,
      right: windowWidth - (data?.right ?? 0),
    };
    // #endif

    // eslint-disable-next-line no-unreachable
    return {
      height: 0,
      width: 0,
      top: 0,
      left: 0,
      bottom: 0,
      right: 0,
    };
  });
  return { statusBarHeight, navBarHeight, menuButtonBounding };
};
